package com.wjw.exception;

import com.wjw.utils.WJWJSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * 2 * @Author: 小王同学
 * 3 * @Date: 2021/1/4 15:53
 * 4
 */
@RestControllerAdvice
public class CustomExceptionHandler {

    /**
     * 上传文件超过500K，捕获异常：MaxUploadSizeExceededException
     * @param ex
     * @return
     */
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public WJWJSONResult handlerMaxUploadFile(MaxUploadSizeExceededException ex) {
        return WJWJSONResult.errorMsg("文件上传大小不能超过500K");
    }

}
